package Demo7;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        //time表示页面访问序列中访问页面的次数
        int time = s.nextInt();
        //表示页面访问序列
        int[] list = new int[time];
        for (int i = 0; i < list.length; i++) {
            list[i] = s.nextInt();
        }
        //表示系统分配给的页框号数量
        int num = s.nextInt();
        int[] array = new int[num];
        //将数组中的所有值都赋值-2
        Arrays.fill(array, -2);
        int count = 0;
        int i, j, k;
        for (i = 0, k = num - 1; i < time; i++) {
            //false 无相同
            //true  有相同
            boolean flag = false;
            for (j = 0; j < num; j++) {
                if (list[i] == array[j]) {
                    flag = true;
                }
            }
            //说明页框中不存在以下的页面序列
            if (!flag) {
                if (len(array) == num) {
                    int change = array[0];
                    for (int l = 0; l < array.length; l++) {
                        int t = array[l];
                        array[l] = change;
                        change = t;
                    }
                    array[0] = list[i];
                } else {
                    array[k--] = list[i];
                }
                count++;
            }
        }
        System.out.println(count);
    }

    public static int len(int[] list) {
        int len = 0;
        for (int j : list) {
            if (j != -2) {
                len++;
            }
        }
        return len;
    }
}



